@extends('linfeng.home.person')
@section('title','修改信息')
@section('first-person')
    <div style="font-size:14px;padding:20px;" class="modal-content">
          <div class="member-security">
        <div class="member-title">
            <h2>安全中心</h2>
        </div>
        <!-- 修改密码 -->
        <div class="member-mod">
            <form action="{{url('home/Person/goin')}}" method="post" >
                {{csrf_field()}}
                <ul>
                    <li class="ps_edit">
                        <span class="security-title">
                            <span class="iconfont glyphicon glyphicon-pencil"></span>
                            <b>密码登陆</b>
                        </span>
                        <span class="security-actions">
                            <button type="button" class="bind_bow btn btn-default" data-toggle="modal" data-target="#myModal">修改</button>
                            <!-- Modal -->
                            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                                <div class="modal-dialog" role="document" style="z-index:1111;">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                        <h4 class="modal-title" id="myModalLabel">修改密码</h4>
                                    </div>
                                    <div class="modal-body">
                                        <div class="email_tx">
                                            <p class="content-msgtext">为了保证您的帐号安全，修改密码前请先进行安全验证</p>
                                            <div>
                                                <span><b>验证方式</b></span>
                                            </div>
                                            <div class="content-type-select">
                                                <div class="passapi-select-show" style="line-height:40px;">
                                                    <input style="width:364px;height:40px;" type="text" name="phone" class="select-show-uname" id="tel" value="{{session('readtel')}}">
                                                    <a id="drop4" href="" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                                                        <span class="phone_an">
                                                             <span class="glyphicon glyphicon-menu-down"></span>
                                                        </span>
                                                    </a>
                                                    <ul id="menu1" style="width:400px;left:98px;top:57%;" class="dropdown-menu" aria-labelledby="drop4">
                                                        <li id="tel"><a href="#"></a>{{session('readtel')}}</li>
                                                        <li><a href="#"></a>短信若接收不到请联系客服!</li>
                                                    </ul>
                                                </div>
                                            </div>
                                            <div class="content-element content-vcode clearfix">
                                                <input type="text" name="code" placeholder="短信验证码" style="margin-top:20px;height:40px;">
                                                <input type="button" class="sent_out btn btn-default" id="goSMS" value="获取验证码">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="modal-footer" style=" border-top:none;text-align:center;">
                                        <input style="width:200px;" class="btn btn-info" type="submit" value="确定">
                                    </div>
                                </div>
                            </div>
                            </div>
                        </span>
                        <span class="security-content">
                            <span class="tixing">请经常更换您的登录密码，且不要和其他账号共用一个密码</span>
                        </span>
                    </li>
                    <li class="ps_edit">
                        <span class="security-title">
                            <span class="iconfont glyphicon glyphicon-pencil"></span>
                            <b>编辑头像</b>
                        </span>
                        <span class="security-actions">
                           <a href="{{url('home/Person/userIcon')}}">修改</a>
                        </span>
                        <span class="security-content">
                            <span class="tixing">请选择你心动的头像</span>
                        </span>
                    </li>
                    <li class="ps_edit">
                        <span class="security-title">
                            <span class="iconfont glyphicon glyphicon-pencil"></span>
                            <b>更换手机</b>
                        </span>
                        <span class="security-actions">
                            <a  id="inuptel">修改</a>
                        </span>
                        <span class="security-content">
                         </form>
                            <span class="tixing">你现在所绑定的手机是:{{$name->tel}}</span>
                            <div class="uptel" style="display: none">
                                    <form action="{{url('home/Person/newtel')}}" class="form-horizontal">
                                        <div class="row">
                                            <div class="col-lg-10">
                                                <b id="guan" style="font-size: 20px;float:right;">×</b>
                                          <div class="form-group gotel">
                                            <label for="inputEmail3" class="col-sm-2 control-label">新号码</label>
                                            <div class="col-sm-10">
                                              <input type="text" class="form-control" name="newtel" id="inputEmail3" placeholder="新号码">
                                            </div>
                                          </div>
                                           <div class="form-group">
                                            <label for="inputPassword3" class="col-sm-2 control-label"></label>
                                            <div class="col-sm-10">
                                              <button type="button" class="btn btn-default" id="SMS">发送短信至新号码
                                            </div>
                                          </div>
                                          <div class="form-group">
                                            <label for="inputPassword3" class="col-sm-2 control-label">新号码短信验证码</label>
                                            <div class="col-sm-10">
                                              <input type="text" class="form-control" name="code" id="inputPassword3" placeholder="Password">
                                            </div>
                                          </div>
                                          <div class="form-group">
                                            <div class="col-sm-offset-2 col-sm-10">
                                             <input type="submit" value="提交" class="btn btn-default">
                                            </div>
                                          </div>
                                          </div>
                                          </div>
                                        </form>
                            </div>
                        </span>
                        {{--ajax短信验证请求--}}
                        <script>
                            $(function(){
                                $('#inuptel').click(function(){
                                    if ($('.uptel').css('display')=='none'){
                                        $('.uptel').css('display','inline')
                                    }else{
                                        $('.uptel').css('display','none')
                                    }
                                })
                                $
                                $('#guan').click(function(){
                                    $('.uptel').css('display','none')
                                })
                                $('#SMS').click(function(){
                                    $newtel=$('#inputEmail3').val();
                                    if($newtel){
                                        $.ajax({
                                            url:'{{url('home/Person/PersonSMS')}}',
                                            data:'tel='+$newtel,
                                            type:'get',
                                            success:function(data){
                                                if (data==333){
                                                    alert('发送成功')
                                                }
                                                if (data==111){
                                                    alert('此号码已注册')
                                                }
                                            },
                                            datatype:'text'
                                        })
                                    }else{
                                        alert('新号码不能为空')
                                    }
                                })
                            })
                        </script>
                    </li>
                    <li class="ps_edit">
                        <span class="security-title">
                            <span class="iconfont glyphicon glyphicon-pencil"></span>
                            <b>邮箱验证</b>
                        </span>
                        <span class="security-actions">
                            <a href="">修改</a>
                        </span>
                        <span class="security-content">
                            <span class="tixing">进行邮箱验证后，可以用户快速找回账号密码和身份验证操作，保护您的账号安全</span>
                        </span>
                    </li>
                    {{--@if(!empty(session('message')))--}}
                        {{--<script>alert('验证码不存在或者不正确')</script>--}}
                    {{--@endif--}}
                    @if(!empty(session('success')))
                        <script>alert('修改成功')</script>
                    @endif
                </ul>

        </div>
    </div>
    </div>
    {{--ajax请求短信验证码--}}
    <script>
        $(function(){
            $('#goSMS').click(function(){

                $tel=$('#tel').val()

                $.ajax({
                    url:"{{url('home/sendSMS')}}",
                    type:'get',
                    data:'tel='+$tel,
                    success:function (data) {
                        $sum=data;
                        $str=$sum.substr(-1);
                        if ($str==222){
                            alert('此号码未注册')
                        }else{
                            alert('短信已发送')
                        }
                    },
                    error:function(){
                        alert('错误');
                    },
                    dataType:'text'
                })
            })
        })
    </script>
@endsection